package online.afeibaili.storebackendframework.server;

import online.afeibaili.storebackendframework.mapper.AdminInfoMapper;
import online.afeibaili.storebackendframework.model.AdminInfo;
import online.afeibaili.storebackendframework.util.Sh256;
import org.springframework.stereotype.Service;

@Service
public class AdminInfoServer {
    private final AdminInfoMapper adminInfoMapper;

    public AdminInfoServer(AdminInfoMapper adminInfoMapper) {
        this.adminInfoMapper = adminInfoMapper;
    }

    public AdminInfo selectByToken(String token) {
        return adminInfoMapper.selectByToken(token);
    }
    public int insert(AdminInfo adminInfo) {
        return adminInfoMapper.insert(adminInfo);
    }
    public AdminInfo selectByToken(String user, String password) {
        String token = Sh256.getSha256Hash(user+password);
        return adminInfoMapper.selectByToken(token);
    }
    public int count() {
        return adminInfoMapper.count();
    }
}
